Skip to content

test(discover): add unit tests for TableCell and TableHeaderColumn#12261

Open
amarkdotdev wants to merge 1 commit into
opensearch-project:mainfrom
amarkdotdev:test/discover-table-coverage
Open

test(discover): add unit tests for TableCell and TableHeaderColumn#12261
amarkdotdev wants to merge 1 commit into
opensearch-project:mainfrom
amarkdotdev:test/discover-table-coverage

Conversation

@amarkdotdev

@amarkdotdev amarkdotdev commented Jun 21, 2026

Copy link
Copy Markdown

Description

Adds unit tests for two previously untested components in src/plugins/discover/public/application/components/default_discover_table/.

table_cell.test.tsx (8 tests)

  • Renders sanitized HTML content correctly
  • Filter-for and filter-out button click handlers
  • Time field styling (eui-textNoWrap) vs non-time field styling (eui-textBreakAll)
  • Truncate-by-height wrapper present only for non-time fields

table_header_column.test.tsx (12 tests)

  • Column display name and data-test-subj rendering
  • Sort button visibility based on isSortable prop
  • Sort order cycling: unsorted → asc → desc → remove/reset
  • Remove button click calls onRemoveColumn
  • Move-left/move-right button visibility and callbacks

Testing

yarn test:jest src/plugins/discover/public/application/components/default_discover_table/table_cell.test.tsx
yarn test:jest src/plugins/discover/public/application/components/default_discover_table/table_header_column.test.tsx

Resolves #7048

Add comprehensive unit tests for the two untested components in the
default_discover_table directory:

- table_cell.test.tsx: Tests rendering of sanitized content, filter
  button interactions (filter-for and filter-out), time field vs
  non-time field styling (eui-textNoWrap vs eui-textBreakAll), and
  truncate-by-height wrapper behavior.

- table_header_column.test.tsx: Tests column name rendering, sort
  button visibility and cycling (unsorted -> asc -> desc -> unsorted
  or back to asc when only sort), remove/move-left/move-right button
  rendering and callbacks, and conditional button visibility based
  on props (colLeftIdx, colRightIdx, isSortable, isRemoveable).

Resolves opensearch-project#7048

Signed-off-by: Aaron Mark <64331623+amarkdotdev@users.noreply.github.com>
@amarkdotdev amarkdotdev force-pushed the test/discover-table-coverage branch from 52f2d0a to 219b799 Compare June 21, 2026 18:38
@amarkdotdev

Copy link
Copy Markdown
Author

Looked into the Code-Diff-Analyzer failure — it's not caused by the test changes in this PR. The job fails at "Set up job" because the workflow references unpinned action versions (actions/setup-node@v6, etc.), which OpenSearch-Dashboards policy blocks:

"all actions must be pinned to a full-length commit SHA"

This appears to be an upstream workflow configuration issue. Retriggered CI with e1f463f7 in case it helps, but the analyzer will likely stay red until the workflow is fixed on the repo side. The actual test code and DCO checks look fine.

@amarkdotdev amarkdotdev force-pushed the test/discover-table-coverage branch 2 times, most recently from b8fa2a1 to 219b799 Compare June 23, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover] Increase test coverage for discover default table

1 participant